package com.atos.smp.actions;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.List;

import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;

import net.codeissue.web.common.ServiceFinder;

import org.primefaces.event.ItemSelectEvent;
import org.primefaces.model.chart.CartesianChartModel;
import org.primefaces.model.chart.ChartSeries;
import org.primefaces.model.chart.LineChartSeries;
import org.primefaces.model.chart.PieChartModel;

import com.atos.smp.beans.Event;
import com.atos.smp.beans.Process;
import com.atos.smp.beans.ProcessesAVGMapper;
import com.atos.smp.beans.SessionEvent;
import com.atos.smp.business.ProcessManager;
import com.atos.smp.business.SessionEventManager;
import com.atos.smp.business.impl.ProcessManagerImpl;
import com.atos.smp.dao.ProcessDao;
import com.atos.smp.util.DateUtil;
import com.atos.smp.util.EventMapper;

import org.primefaces.event.DateSelectEvent;

@ManagedBean
@SessionScoped
public class SessionEventBean implements Serializable {
	
	private SessionEventManager sessionEventManager;
	private CartesianChartModel cartesianChartModel;
	private PieChartModel pieChartModel;
	private String das = "A528594";
	
	public CartesianChartModel getCartesianChartModel() {
		return cartesianChartModel;
	}

	public void setCartesianChartModel(CartesianChartModel cartesianChartModel) {
		this.cartesianChartModel = cartesianChartModel;
	}

	public SessionEventBean() {
		sessionEventManager = Action.getSessionEventManager();
		cartesianChartModel = new CartesianChartModel();
		pieChartModel = new PieChartModel();
		List<SessionEvent> sessionEvent = sessionEventManager.findAllSessionEvent(das);
		
		for (SessionEvent se : sessionEvent) {
			
			
			pieChartModel.set(se.getEvent().toString(),se.getDate().getDate());
			ChartSeries dL = new ChartSeries();
			dL.setLabel("test");
			dL.set("date1", EventMapper.get(se.getEvent()));
			System.out.println(se);
			cartesianChartModel.addSeries(dL);
		}

		
		
	}

	public PieChartModel getPieChartModel() {
		return pieChartModel;
	}

	public void setPieChartModel(PieChartModel pieChartModel) {
		this.pieChartModel = pieChartModel;
	}

}
